/**
 * Created by wubo on 2018/3/11.
 */
define(function (require, exports, module) {
    require("vue");
    require("jqGrid");
    require("element");

    //表格宽度自适应
    $(function(){
        $(window).resize(function(){
            $("#moduleListTable").setGridWidth($("#moduleApp").width());
        });
    });

    var moduleApp = new Vue({
        el: "#moduleApp",
        data: function () {
            return {};
        },
        mounted: function () {
            $("#moduleListTable").jqGrid(
                {
                    datatype: "local",
                    width: "100%",
                    height: "100%",
                    autowidth: true,
                    colNames: ['模块名', '安装日期', '分布人', '大小', '版本', '位置', '操作'],
                    colModel: [{
                        name: 'id',
                        index: 'id',
                        width: 100,
                        align: "left",
                        sorttype: "int",
                    }, {
                        name: 'invdate',
                        index: 'invdate',
                        align: "left",
                        width: 80,
                        sorttype: "date"
                    }, {
                        name: 'name',
                        index: 'name',
                        width: 100,
                        align: "left"
                    }, {
                        name: 'amount',
                        index: 'amount',
                        width: 100,
                        align: "left",
                        sorttype: "float"
                    }, {
                        name: 'tax',
                        index: 'tax',
                        align: "left",
                        sorttype: "float"
                    }, {
                        name: 'total',
                        index: 'total',
                        align: "left",
                        sorttype: "float"
                    }, {
                        name: 'op',
                        index: 'note',
                        align: "center",
                        formatter: function(cellvalue,options, rowObject) {
                            return "<a class='t-op-link'>查看</a>|<a class='t-op-link'>修改</a>|<a class='t-op-link'>卸载</a>"
                        }
                    }],
                    multiselect: true,
                    //caption : "Manipulating Array Data"
                });

            var mydata = [
                {id : "合同管理",invdate : "2007-10-01",name : "吴波",note : "note",amount : "200.00KB",tax : "0.01",total : "/contract"},
                {id : "2",invdate : "2007-10-02",name : "test2",note : "note2",amount : "300.00",tax : "20.00",total : "320.00"},
                {id : "3",invdate : "2007-09-01",name : "test3",note : "note3",amount : "400.00",tax : "30.00",total : "430.00"},
                {id : "4",invdate : "2007-10-04",name : "test",note : "note",amount : "200.00",tax : "10.00",total : "210.00"},
                {id : "5",invdate : "2007-10-05",name : "test2",note : "note2",amount : "300.00",tax : "20.00",total : "320.00"},
                {id : "6",invdate : "2007-09-06",name : "test3",note : "note3",amount : "400.00",tax : "30.00",total : "430.00"},
                {id : "7",invdate : "2007-10-04",name : "test",note : "note",amount : "200.00",tax : "10.00",total : "210.00"},
                {id : "8",invdate : "2007-10-03",name : "test2",note : "note2",amount : "300.00",tax : "20.00",total : "320.00"},
                {id : "9",invdate : "2007-09-01",name : "test3",note : "note3",amount : "400.00",tax : "30.00",total : "430.00"}
            ];
            for ( var i = 0; i <= mydata.length; i++){
                $("#moduleListTable").jqGrid('addRowData', i + 1, mydata[i]);
            }
        }
    });
})